var app = getApp();

Page({
  data: {
    starMap: [
      { id: '1', value: '1星' },
      { id: '2', value: '2星' },
      { id: '3', value: '3星' },
      { id: '4', value: '4星' },
      { id: '5', value: '5星' }
    ]
  },
  onLoad: function (options) {
    var that = this;
    var comment = JSON.parse(options.comment);
    var star = parseInt(comment.type.replace("review_", ""));
    var comment_text = comment.type_text.split("|");
    that.setData({
      star: star,
      comment_text: comment_text,
      time: app.formatTime(comment.add_time, 'Y-M-D h:m'),
      user_id: comment.user_id
    })
    //console.log(comment);
    that.getData();
  },
  getData: function () {
    var that = this;
    app.JsonPost("Api/User/index", {
      user_id: that.data.user_id
    }, function (res) {
      that.setData({
        userName: res.user_name,
        avatar: res.avatar
      })
    });
  }
})